//
// Created by LvenLiu on 2022/3/25.
//

#ifndef FFMPEGDEMO_FFPLAYER_H
#define FFMPEGDEMO_FFPLAYER_H

#include <string>
#include <pthread.h>
#include "JNICallback.h"
#include "AndroidLog.h"
#include "ErrorCode.h"
#include "VideoChannel.h"

extern "C" {
#include <libavformat/avformat.h>
}

using namespace std;

/**
 * 音视频播放器
 */
class FFPlayer {
private:
    char *path = 0; // 视频路径
    JNICallback *callback = 0; // 回调
    pthread_t prepare_pid;// 准备线程
    pthread_t start_pid;// 开始线程
    // 开始状态
    bool isStar;
    RenderCallback renderCallback;
public:
    FFPlayer();

    ~FFPlayer();

    void prepare();

    void prepare_();

    void onPrepared(int thread_mode);

    void onError(int thread_mode, int error_code, char *msg);

    void setPath(const char *path);

    void setCallback(JNICallback *callback);

    void setRenderCallback(RenderCallback renderCallback);

    void start();

    void start_();
};


#endif //FFMPEGDEMO_FFPLAYER_H
